﻿using LoveEat.API.Write.Applications.Commands.Deep;
using LoveEat.Domain.Deep;
using LoveEat.ErrorCode;
using LoveEat.Infrastructure.Interfaces;
using MediatR;

namespace LoveEat.API.Write.Applications.CommandHandlers.Deep
{
    public class AddDeepCommandHandler : IRequestHandler<AddDeepCommand, APIResult<int>>
    {
        private readonly IBaseRespository<DeepModel> deepRep;

        public AddDeepCommandHandler(IBaseRespository<DeepModel> deepRep)
        {
            this.deepRep = deepRep;
        }

        public async Task<APIResult<int>> Handle(AddDeepCommand request, CancellationToken cancellationToken)
        {
            APIResult<int> result = new APIResult<int>();
            result.Code=APIResultCode.添加成功;
            result.Message=APIResultCode.添加成功.ToString();

            DeepModel deep=new DeepModel();
            deep.Team=request.Team;
            deep.charge=request.charge;
            deep.Batch=request.Batch;
            deep.ComName=request.ComName;
            deep.Pronumber=request.Pronumber;
            deep.IsDelete=false;
            await deepRep.AddAsync(deep);



            return await Task.FromResult(result);
        }
    }
}
